﻿#!/usr/bin/env python
#coding:utf-8
#Code by Mango


class pygeplugin:
    infos = [
        ['Plugin','scan port for thread'],
        ['by','mst'],
        ['version','2.0'],
        ['update','20131026'],
        ]
    opts  = [
        ['RHOST','127.0.0.1','Scan Target IP'],
        ]
    ports = [
        ['21','FTP'],
        ['22','SSH'],
        ['23','TELNET'],
        ['25','SMTP'],
        ['80','HTTP'],
        ['135','SMB'],
        ['139','SMB'],
        ['443','HTTPS'],
        ['445','SMB'],
        ['1080','PROXY'],
        ['1433','MSSQL'],
        ['1723','VPN'],
        ['3306','MYSQL'],
        ['3389','MSTSC'],
        ['5432','POSTGRE'],
        ['8080','PROXY']
        ]
    def run(self):
        color.cprint("    %-32s %-8s %-10s %-20s"%("RHOST","PORT","STATUE","DESCRIPTION"),YELLOW)
        color.cprint("    %-32s %-8s %-10s %-20s"%("-"*32,"-"*8,"-"*10,"-"*20),GREY)
        ths=[]
        def th(port,desc):
            if fuck.checkport(RHOST,port):
                color.cprint("    %-32s %-8s %-10s %-20s"%(RHOST,port,"OPEN",desc),GREEN)
            else:
                color.cprint("    %-32s %-8s %-10s %-20s"%(RHOST,port,"CLOSE",desc),WHITE)
        for p in self.ports:
            t = threading.Thread(target=th,args=(p[0],p[1]))
            t.start()
            time.sleep(0.3)
            ths.append(t)
        for t in ths:
            t.join()
